<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>01.let的使用</title>
</head>

<body>
  <script>
    /* 
     *ES6中let的使用：
     *1.可以同时声明多个变量
     *2.
     */
    //1.声明变量
    let a = 10,
      b = 20,
      c = 30;
    let str1 = "i love you";
    let arr = [],
      bool = true,
      func = function () {

      },
      obj = {
        "name": "jason",
        "age": 20,
      };
    //2.不能重复声明变量
    let strName = "jason";
    //let strName = "tom"; // Identifier 'strName' has already been declared
    //console.log(strName);
    //3.块级作用域：全局,函数,eval
    //if else while for里面也存在代码块
    {
      let girl = "grace";
    }
    //console.log(girl);//girl is not defined

    //3.不存在变量提升
    console.log(song);//Uncaught ReferenceError: Cannot access 'song' before initialization
    let song = "恋爱达人";

    //4.不影响作用域链
    {
      let school = "尚硅谷";

      function fn() {
        console.log(school);
      }
      fn();
    }
  </script>
</body>

</html>